﻿
#region USING STATEMENTS

using Microsoft.Xna.Framework.Graphics; // For Texture2D
using Microsoft.Xna.Framework; // For Vector2

#endregion USING STATEMENTS

namespace BrickBreaker.Core
{
    public class BBBackground
    {
        #region DATA MEMBERS

        private Texture2D texture;
        private Vector2 position;
        private Vector2 size;
        private Vector2 scale;

        #endregion DATA MEMBERS



        #region OBJECT CONSTRUCTION

        /// <summary>
        /// Creates a new background to be used. Default Position is Top Left
        /// of screen, and Default Scale is 100% scale.
        /// </summary>
        /// <param name="newTexture">The background texture</param>
        public BBBackground(Texture2D newTexture)
        {
            this.texture = newTexture;
            this.position = new Vector2(0, 0);
            this.size = new Vector2(newTexture.Width, newTexture.Height);
            this.scale = new Vector2(1, 1);
            
        }// end Constructor()

        /// <summary>
        /// Creates a new background to be used. Default Position is Top Left
        /// of screen, and scale is based off the size specified with respect
        /// to the screen.
        /// </summary>
        /// <param name="newTexture">The background texture</param>
        /// <param name="size">The size of the background</param>
        public BBBackground(Texture2D newTexture, Vector2 size)
        {
            this.texture = newTexture;
            this.position = new Vector2(0, 0);
            this.size = size;
            this.scale = new Vector2((BBGlobalConfig.getWindowWidth() / size.X), (BBGlobalConfig.getWindowHeight() / size.Y));
        }// end Overloaded Constructor 1()

        /// <summary>
        /// Creates a new background to be used. Position is set to the specified
        /// location. Default Scale is 100% scale.
        /// </summary>
        /// <param name="newTexture">The background texture</param>
        /// <param name="position">The position of the background</param>
        /// <param name="size">The size of the background</param>
        public BBBackground(Texture2D newTexture, Vector2 position, Vector2 size)
        {
            this.texture = newTexture;
            this.position = position;
            this.size = size;
            this.scale = new Vector2(1, 1);
        }

        #endregion OBJECT CONSTRUCTION



        #region PROPERTIES

        public Texture2D Texture
        {
            get{ return texture; }
            set{ texture = value; }
        }

        public Vector2 Position
        {
            get{ return position; }
            set{ position = value; }
        }

        public Vector2 Size
        {
            get { return size; }
            set { size = value; }
        }

        #endregion PROPERTIES



        #region PUBLIC METHODS

        /// <summary>
        /// Draws the background.  Call this in a spritebatch.Begin()/End() block.
        /// </summary>
        /// <param name="spriteBatch">Your spritebatch.  Make sure you have already called begin().</param>
        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(texture, position, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
        } 

        #endregion PUBLIC METHODS 
    
    }// end class
}// end namespace
